#-*- coding: big5 -*-
from modelRepository import modelRepository
from view import ViewBook
from controller import controllerBook,assignDefaultBook
from serialize import reflectionSerialzeXml
from pagedDocument import PagedDocumentFileCreator,PagedDocumentHtml,PagedDocumentText

def testXml():
    assignDefaultBook()
    controllerBook.new('Chapter','c3','Chapter3')
    controllerBook.new('Paragraph','p3','This is new paragraph 1 of Chapter 3')
    controllerBook.add('c3','p3')
    controllerBook.add('modelBook','c3')
    controllerBook.show()
    reflectionSerialzeXml.saveXml()

def testPage():
    assignDefaultBook()
    controllerBook.showFirstPage()

def testAbstractFactory(abstractPagedDocument,strOutputDirectory):
    book=modelRepository.getModelBook()
    pagedDocumentFileCreator=PagedDocumentFileCreator(book,abstractPagedDocument)
    pagedDocumentFileCreator.traverseBookCreatePagedDocument()
    pagedDocumentFileCreator.savePages(strOutputDirectory)

def testAbstractFactoryHtml():
    testAbstractFactory(PagedDocumentHtml(),'./html/')

def testAbstractFactoryText():
    testAbstractFactory(PagedDocumentText(),'./text/')
    
if __name__=='__main__':
    assignDefaultBook()
    testAbstractFactoryHtml()
    testAbstractFactoryText()
